﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using MYNAMESPACE;

namespace final_project
{
    public partial class ATM_Account : Form
    {
        private connect_db con;
        public string nm2;
        public string passvalue
        {

            get
            {
                return nm2;
            }
            set
            {
                nm2 = value;
            }

        }
        public ATM_Account()
        {
            InitializeComponent();
        }

        private void ATM_Account_Load(object sender, EventArgs e)
        {
            ID.Text = nm2;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            user us = new user();
            us.setnational_id(Int32.Parse(ID.Text.Trim()));
            con = new connect_db();
            con.sqlquery("select * from userdata where id= (@namep) ");
            con.cmd.Parameters.Add("@namep", us.getnational_id());
            con.sqlnonex();
            int c = 0;
            foreach (DataRow dr in con.QueryEx().Rows)
            {

                UserData.Items.Add("the id is " + dr[0].ToString());
                UserData.Items.Add("the name is " + dr[1].ToString());
                UserData.Items.Add("the pass is " + dr[2].ToString());
                UserData.Items.Add("the adreess is " + dr[3].ToString());
                UserData.Items.Add("the mail is " + dr[4].ToString());
                UserData.Items.Add("the phone is " + dr[5].ToString());
                UserData.Items.Add("the gender is " + dr[6].ToString());
                UserData.Items.Add("the balance is " + dr[8].ToString());
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            
            user us = new user();
            con = new connect_db();
            us.setnational_id(Int32.Parse(ID.Text));
            con.sqlquery("select balance from userdata where id=(@namep)");
            con.cmd.Parameters.Add("@namep", us.getnational_id());
            foreach (DataRow dr in con.QueryEx().Rows)
            {

                Balance.Text = dr["balance"].ToString();
            }
            this.Hide();
            ATM_Withdrow ATW = new ATM_Withdrow();
            ATW.passvalue = ID.Text;
            ATW.passvalue1 = Balance.Text;
            ATW.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
           // this.Hide();
            user us = new user();
            us.setnational_id(Int32.Parse(ID.Text.Trim()));
            con = new connect_db();
            con.sqlquery("select balance from userdata where id=(@namep)");
            con.cmd.Parameters.Add("@namep", us.getnational_id());
            foreach (DataRow dr in con.QueryEx().Rows)
            {

                Balance.Text = dr["balance"].ToString();
            }


            con.sqlquery("select companydata.name from userdata , companydata where  userdata.Co_id=companydata.Co_id  and id=(@namep)");
            con.cmd.Parameters.Add("@namep",us.getnational_id());
            foreach (DataRow dr in con.QueryEx().Rows)
            {

                Company_ID.Text = dr[0].ToString();
            }
          

            con.sqlquery("select phone from userdata where id=(@namep)");
            con.cmd.Parameters.Add("@namep", us.getnational_id());
            foreach (DataRow dr in con.QueryEx().Rows)
            {

                Phone.Text = dr["phone"].ToString();
            }

       
            this.Hide();
            ATM_recharge REC = new ATM_recharge();
            REC.passvalue = ID.Text;
            REC.passvalue1 = Balance.Text;
            REC.passvalue5 = Phone.Text;
            REC.passvalue6= Company_ID.Text;
            REC.ShowDialog();

        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.Hide();
            Home H = new Home();
            H.ShowDialog();
        }
    }
}
